package cn.zktr.Personnel.controllers.zhouxiong;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.zktr.Personnel.model.service.zhouxiong.*;
import cn.zktr.Personnel.model.uitls.EmpSli;

@Controller
public class PaiBanController {
	
	@Autowired
	private KaoQinKaService kqk;
	@Autowired
	private JiChuService jichu;
	
	@RequestMapping("zx/pai-ban")
	public void zhujiemian(Model model) {
//		kaoqin( model);
	}
	
	@RequestMapping("PaiBan")
	@ResponseBody
	public Map<String,Object> paiban(String Str,int page,int rows) {
		Map<String,Object> map = new HashMap<>();
		map.put("total",kqk.selePaiBan(Str).size());
		Page<Object> p=PageHelper.startPage(page,rows);
		JSONArray findAll=kqk.selePaiBan(Str);
		//页内容
		map.put("rows",findAll);
		return map;
	}
	
	@RequestMapping("PBdeptemp")
	@ResponseBody
	public JSONArray deptemp(Integer cwasid) {
		return kqk.deptemp(cwasid);
	}
	
	@PostMapping("updatePB1")
	@ResponseBody
	public String updatePBsa(Integer cwasid,String[] jsons) {
		kqk.tiaobanUP(cwasid, jsons);
		return "";
	}
	 
	@PostMapping("updatePB")
	@ResponseBody
	public String updatePBs(Integer cwasid,Integer empidsl) {
//		kqk.tiaobanUP(cwasid, jsons);
		kqk.updatebz(cwasid, empidsl);
		return "";
	}
	
	@PostMapping("updatePBs")
	@ResponseBody
	public String updatePB(Integer cwasid,Integer EMPID) {
		kqk.updatePB( cwasid, EMPID);
		return "";
	}
	
	@PostMapping("deletePB")
	@ResponseBody
	public String deleteBC(Integer kprid,Model model) {
		kqk.deletePB(kprid);
//		kaoqin( model);
		return "";
	}
	
//	public void kaoqin(Model model) {
//		model.addAttribute("KaoQinKa", kqk.seleKaoQinKa());					//考勤卡
//		model.addAttribute("PaiBan", kqk.selePaiBan());                       //排班
//		model.addAttribute("YuanYin", jichu.seleYuanYin());                   //原因
//		model.addAttribute("BanCi", jichu.selectBanCi());                     //班次
//		model.addAttribute("BanZu", jichu.selectBanZu());                     //班组
//		model.addAttribute("QinJiaZhongLei", jichu.seleQinJiaZhongLei());     //请假种类
//	}
}
